package cn.dengta.webapp.user.vo;

import java.util.List;
import java.util.Map;

import cn.dengta.context.model.Option;
import cn.dengta.webapp.base.vo.AbstractVO;
import cn.dengta.webapp.user.entity.User;
import lombok.Getter;
import lombok.Setter;
import me.codeplayer.util.CollectionUtil;
import me.codeplayer.util.StringUtil;

@Getter
@Setter
public class ModuleConfigVO extends AbstractVO<User> {

	/** 首页展示用户语言筛选 */
	public Map<String, Object> languages;
	/** 首页展示用户国家筛选 */
	public Map<String, Object> countries;

	public void initLanguages(boolean open, List<Option<String>> languages, String userLanguage) {
		if (open) {
			this.languages = CollectionUtil.ofHashMap("userLanguage", userLanguage, "languages", languages);
		}
	}

	public void initCountries(boolean open, List<Map<String, String>> countries, String userCountry) {
		if (open) {
			this.countries = CollectionUtil.ofHashMap("userCountry", StringUtil.isEmpty(userCountry) ? null : userCountry, "countries", countries);
		}
	}

}
